<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>

<style type="">
	.mini-radiobuttonlist-item{
		padding: 10px;
	}
</style>

</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">

	<div class="mini-fit" >
    	<h2 style="margin-left: 15px;">话务任务保存设置</h2>
    	<div id="task_save" class="mini-radiobuttonlist" repeatItems="2" repeatLayout="table" repeatDirection="vertical"
    		textField="text" valueField="id" data="contactType" onvaluechanged="saveSet"></div>
    		
    	<h2 style="margin-left: 15px;">软交换数据同步</h2>	
    	<a class="mini-button" iconCls="icon-reload" onclick="syncData(1)" style="margin-left: 15px;">同步中继数据</a>	
    	<a class="mini-button" iconCls="icon-reload" onclick="syncData(2)" style="margin: 15px;">同步呼入路由数据（外线号码）</a>	
    	<a class="mini-button" iconCls="icon-reload" onclick="syncData(3)">同步队列数据</a>	<br />
    	<a class="mini-button" iconCls="icon-reload" onclick="syncData(4)" style="margin: 15px;">同步分机号数据</a>
    	
    	<h2 style="margin-left: 15px;">软交换服务器ip及端口设置（用于试听录音）</h2>
    	<div id="set_ip_div">
	    	<span style="margin-left: 15px;">服务器ip:</span>
	    	<input style="width: 180px;" name="serverIp" class="mini-textbox" required="true" vtype="maxLength:20;ipType" />
	    	<a class="mini-button" onclick="onOk" style="width:50px;margin-left: 25px;">确定</a>
    	</div>
    		
    </div>
<script type="text/javascript">

var contactType = [{id:"1",text:"保存到话务部"}, {id:"2",text:"保存到话务员"}, {id:"3",text:"散线保存到话务员、热线保存到话务部"}, {id:"4",text:"散线保存到话务部、热线保存到话务员"}];
mini.parse();

var taskSave = mini.get("task_save");
// 设置值
$.post("task_save_get_val.do", function(data) {
	taskSave.setValue(data.taskSaveVal);
	mini.getbyName("serverIp").setValue(data.serverIp);
}, "json");

function saveSet(e) {
	$.post("task_save_edit_val.do",{keyName: e.value}, function(data) {
		mini.showMessageBox({
            title: "提示",
            showModal:false,
            iconCls: "mini-messagebox-info",
            message: "修改成功！",
            timeout: 3000,
            x: 'right',
            y: 'bottom'
        });
	}, "json");
}

// 同步数据
function syncData(type) {
	$.post("sync_cti_data.do", {typeName: type}, function(data) {
		if(data.success) {
			mini.showMessageBox({
	            title: "提示",
	            showModal:false,
	            iconCls: "mini-messagebox-info",
	            message: "数据同步成功！",
	            timeout: 3000,
	            x: 'right',
	            y: 'bottom'
	        });
		}
	}, "json");
}

// 设置服务器ip
function onOk() {
	var form1 = new mini.Form("set_ip_div");
	var o = form1.getData();
	form1.validate();
	if(form1.isValid() == false) return;
	$.post("set_server_ip.do", {keyValue: o.serverIp}, function(data) {
		if(data.success) {
			mini.showMessageBox({
	            title: "提示",
	            showModal:false,
	            iconCls: "mini-messagebox-info",
	            message: "操作成功！",
	            timeout: 3000,
	            x: 'right',
	            y: 'bottom'
	        });
		} else {
			mini.alert("设置失败，ip不能为空");
		}
	}, "json");
}

//验证ip格式
	mini.VTypes["ipTypeErrorText"] = "不能输入中文和英文";
	mini.VTypes["ipType"] = function (v) {
	var reIp = new RegExp("^[\u4e00-\u9fa5]+$");
 	var re = new RegExp("^[a-zA-Z\_]+$");
	if(!reIp.test(v) && !re.test(v)) {
		return true;
	} else {
		return false;
	}
}
</script>
</body>
</html>